home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 4,401 to 4,500 / aol-file-protocol-4400-4401-to-4500.zip / AOLDLs / PDA-Newton Development / ND Newt Development Environm / newt-devenv-31.sit / graphic0.nwt < prev    next >
Text File  |  1995-01-22  |  3KB  |  125 lines

  1. Notes
  2. {labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business.  remove viewFont for current Styles default
  3. //ERASE! in order to erase existing entries in this folder first
  4.  
  5. graphic0.nwt -- Slurpee format
  6. 1/1/95
  7. Copyright 1994, 1995 S. Weyer.  All Rights Reserved Worldwide.
  8. To be distributed only with Newt 2.5 package
  9.  
  10. introductory Newt graphics examples
  11.  
  12. sources for: poly, poly2, polyspi, squiral, cCurve, house, rect
  13.  
  14. see graphic1.nwt for: squiral2 (interruptible version), dCurve,
  15. fractal, hilbert, fourNewts (multiple Newts), tree
  16.  
  17. see NewtTurT -- interactive tutorial for more description
  18.  
  19. To minimize text entry, use the Slurpee utility and a terminal emulator to
  20. transfer this text file as paragraphs in the Notepad.  The folder in 2nd line
  21. is currently set on nil (Unfiled); select same folder in Newt to load.
  22.  
  23. ----------
  24. poly2
  25. //:poly2 (5,80,360/5,0)
  26. //:poly2 (5,80,180-180/5,0)
  27. //:poly2 (times,dist,deg,90)
  28. func(nsides,len,ang,ang2)
  29. // poly with an extra turn at end for squiral & squiral2
  30. // also, ang precomputed & passed
  31. // assumes nsides already checked
  32. begin
  33.     local i;
  34.     for i:=1 to nsides
  35.     do begin
  36.         :go(len); :turn(ang);
  37.         end;
  38.     :turn(ang2);
  39. end
  40. ----------
  41. poly
  42. //:poly (4,100)
  43. //:poly (times,dist)
  44. //local i; for i:=3 to times do :poly(i,dist)
  45. //:poly(Random(3,15),Random(10,20))
  46. func (nsides,len)
  47. if nsides>0
  48. then :poly2(nsides, len, 360/nsides, 0)
  49. else :beep()
  50. ----------
  51. squiral
  52. //:squiral (10,75)
  53. //:squiral (times,dist)
  54. //:addNewt('[[newt1,-55,75,1],[newt2,55,75,2],[newt3,55,-75,1],[newt4,-55,-75,2]],nil,nil,nil)
  55. //newt1:poly2(5,40,144,0)
  56. //:squiral (8,40)
  57. //:cCurve (6,4,0)
  58. func (num,len)
  59. // draw <num> squares
  60. // each of size <len>
  61. // after each, turn 360/num
  62. if num>0
  63. then begin
  64.     local i, ang2:=360/num;
  65.     for i:=1 to num
  66.     do :poly2 (4,len,90,ang2);
  67.     end
  68. else :beep()
  69. ----------
  70. cCurve
  71. //:cCurve (6,8,0)
  72. //:cCurve (8,4,0)
  73. //:cCurve (times,dist,deg)
  74. func(num,dist,deg)
  75. if num>0 // warning num>8 could take awhile...
  76. then begin // the double-recursion (not a simple "tail recursion")
  77.     :cCurve(num-1, dist, deg+45);
  78.     :cCurve(num-1, dist, deg-45);
  79.     end
  80. else begin // where the actual drawing occurs
  81.     :turnTo(deg);
  82.     :go(dist);
  83.     end
  84. ----------
  85. polyspi
  86. //:polyspi (100,10,89)
  87. //:polyspi (times,dist,deg)
  88. func(num,size,angle)
  89. begin
  90.     local i;
  91.     for i:=1 to num
  92.     do begin
  93.         :go(size); :turn(angle);
  94.         size:=size+1;
  95.         end;
  96. end
  97. ----------
  98. house
  99. //:house (dist)
  100. func(size)
  101. begin
  102.   local dht := size/4, dwid := size/8;
  103.   local wsize := dwid;
  104.   :poly(4,size);
  105.   :turn(90); :go(dht); :turn(-90);
  106.   :rect(dht,dwid); // door
  107.   :move(3*dht);
  108.   :poly(4,wsize); // window
  109.   :turn(90); :move(size/2); :turn(-90);
  110.   :poly(4,wsize); // window
  111. end
  112. ----------
  113. rect
  114. func(side1,side2)
  115. begin
  116.     local i;
  117.     for i:=1 to 2
  118.     do begin
  119.         :go(side1); :turn(90);
  120.         :go(side2); :turn(90);
  121.         end;
  122. end
  123. ----------
  124. BYE!
  125.